package com.jy.servlet;

import com.alibaba.fastjson.JSON;
import com.jy.bean.Orderdetail;
import com.jy.service.Orderservice;
import com.jy.service.impl.OrderSericelmpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class merchant_orderListServlet extends HttpServlet {
    private static final Logger log = LoggerFactory.getLogger(merchant_orderListServlet.class);
    private static Orderservice orderservice;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        orderservice = new OrderSericelmpl();
        List<Orderdetail> orderlies = orderservice.consigneeList();
        log.debug("打印所有订单信息" + orderlies);

        String data = JSON.toJSONString(orderlies);

        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        out.println(data);
        log.debug("data:" +data);
    }
}
